/*
 *接口编写处...
*如果接口需要做Action的权限验证，请在Action上使用属性
*如: [ApiActionPermission("tb_project_sourceinfo",Enums.ActionPermissionOptions.Search)]
 */
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.AspNetCore.Http;
using MYData.Entity.DomainModels;
using MYData.System.IServices;
using MYData.Core.Utilities;
using System.Net;

namespace MYData.System.Controllers
{
    /// <summary>
    /// 项目来源控制器
    /// </summary>
    public partial class tb_project_sourceinfoController
    {
        private readonly Itb_project_sourceinfoService _service;//访问业务代码
        private readonly IHttpContextAccessor _httpContextAccessor;

        [ActivatorUtilitiesConstructor]
        public tb_project_sourceinfoController(
            Itb_project_sourceinfoService service,
            IHttpContextAccessor httpContextAccessor
        )
        : base(service)
        {
            _service = service;
            _httpContextAccessor = httpContextAccessor;
        }

        /// <summary>
        /// 根据编码获取对应的项目
        /// </summary>
        /// <param name="dicCode"></param>
        /// <returns></returns>
        [HttpGet, Route("GetSourceList")]
        public async Task<IActionResult> GetSourceListAsync(string? dicCode= "XMLY")
        {
            return Json(await _service.GetSourceListAsync(dicCode));
        }
        /// <summary>
        /// 获取所有项目来源信息（递归）
        /// MJZ 2023/3/29/15/49
        /// </summary>
        /// <returns></returns>
        [HttpGet, Route("GetSourceInforAsync")]
        public async Task<IActionResult> GetSourceInforAsync()
        {
            return Json(await _service.GetSourceInforAsync());
        }
    }
}
